﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace Lab6
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamReader f = File.OpenText("C:\\Temp\\file.txt");
            Console.WriteLine("Enter number");
            string s = Console.ReadLine();
            int n = int.Parse(s);
            int bestDiff = 1000000;
            string l = null;
            string line = null;
            line = f.ReadLine();

            while (line != null)
            {
                string[] sp = line.Split('\t');
                int key = int.Parse(sp[0]);
                int diff = n - key;
                if(diff<0)
                {
                    diff = -diff;
                }

                if (diff < bestDiff || l == null)
                {
                    bestDiff = diff;
                    l = sp[1];
                }
                line = f.ReadLine();
            }
            f.Close();
            Console.WriteLine("Value is {0}",l);
            Console.ReadKey();
        }
    }
}
